<?php


namespace App\Models;


use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;

class ConsumableStock extends Model
{
    protected $table = 'consumable_stock';

    protected $fillable = [
        'type', 'stock', 'remark', 'consumable_id'
    ];

    protected static function boot()
    {
        static::addGlobalScope('orderBy', function (Builder $query){
            $query->orderByDesc('id');
        });
        parent::boot();
    }

    /**
     * @return \Illuminate\Database\Eloquent\Relations\BelongsTo
     * @author luffyzhao@vip.126.com
     */
    public function consumable(){
        return $this->belongsTo(Consumable::class);
    }
}
